#include "../comm.h"
class Solution {
public:
    std::string doubleToString(double value) {
        std::ostringstream out;
        // 设置输出格式为固定小数点，且保留两位小数
        out << std::fixed << std::setprecision(2) << value;
        return out.str();
    }

    string discountPrices(string sentence, int discount) {
        istringstream in(sentence);
        string ans, tmp;
        bool is_first = true;
        while (in >> tmp)
        {
            // cout << tmp << endl;
            if (!is_first)
                ans += ' ';
            is_first = false;

            if (tmp[0] != '$')
                ans += move(tmp);
            else
            {
                // 如果只有单个字符，不需要转换
                if (tmp.size() == 1) {
                    ans += move(tmp);
                    continue;
                }
                bool isdig = true;
                for (int i = 1; i < tmp.size(); ++i)
                    if (!isdigit(tmp[i]))
                    {
                        isdig = false;
                        break;
                    }
                if (!isdig) {
                    ans += move(tmp);
                    continue;
                }
                ans += '$';
                istringstream ss(tmp.substr(1));
                long long pre;
                ss >> pre;
                // cout << pre << ((double)pre / 2) << endl;
                // cout << doubleToString((double)pre * discount / 100.0) << endl;
                ans += doubleToString((double)pre * (100 - discount) / 100.0);
            }
        }
        return ans;
    }
};